package array

func wiggleMaxLength(nums []int) int {

	res := 1

	if len(nums) < 2 {
		return res
	}

	var preDiff, curDiff int

	for i := 0; i < len(nums); i++ {
		curDiff = nums[i+1] - nums[i]
		if (curDiff > 0 && preDiff <= 0) || (curDiff < 0 && preDiff >= 0) {
			preDiff = curDiff
			res++
		}
	}

	return res

}
